package com.example.myapplication7;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //initView();
        initView1();
    }
  /*  private void initView(){
        TextView mlmageAnim = findViewById(R.id.image_anim);
        AnimationDrawable anim = (AnimationDrawable) mlmageAnim.getBackground();
        Button buttona = findViewById(R.id.btn_a);
        Button buttonb = findViewById(R.id.btn_b);
        buttona.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               anim.start();
            }
        });
        buttonb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                anim.stop();
            }
        });
    }*/

    private void initView1(){
     /*   //所有补间动画父类为Animation
        //渐变动画
       ImageView animition = findViewById(R.id.image_alpha_anim);
        Animation alpha =  AnimationUtils.loadAnimation(this,R.anim.an);
        animition.setAnimation(alpha);

        //缩放动画
        ImageView animition2 = findViewById(R.id.image_alpha_anim2);
        Animation alpha2 =  AnimationUtils.loadAnimation(this,R.anim.anim_scale);
        animition2.setAnimation(alpha2);
        //移动动画
        ImageView animition3 = findViewById(R.id.image_alpha_anim3);
        Animation alpha3 =  AnimationUtils.loadAnimation(this,R.anim.anim_trarsiate);
        animition3.setAnimation(alpha3);
        //旋转动画
        ImageView animition4 = findViewById(R.id.image_alpha_anim4);
        Animation alpha4 =  AnimationUtils.loadAnimation(this,R.anim.anim_rotate);
        animition4.setAnimation(alpha4);
        */

        //弹簧动画
        ImageView animition4 = findViewById(R.id.image_alpha_anim4);
        Animation alpha4 =  AnimationUtils.loadAnimation(this,R.anim.anim_trarsiate);
        animition4.setAnimation(alpha4);
      /*  TranslateAnimation tanhuang = new TranslateAnimation(0f,0f,200f,200f);
        tanhuang.setFillAfter(true);*/
        /*ImageView animition4 = findViewById(R.id.shizhne);
        Animation alpha4 =  AnimationUtils.loadAnimation(this,R.anim.anim_rotate3);
        animition4.setAnimation(alpha4);
        ImageView animition5 = findViewById(R.id.fenzhen);
        Animation alpha5 =  AnimationUtils.loadAnimation(this,R.anim.anim_rotate2);
        animition5.setAnimation(alpha5);
        ImageView animition6= findViewById(R.id.miaozhen);
        Animation alpha6=  AnimationUtils.loadAnimation(this,R.anim.anim_rotate);
        animition6.setAnimation(alpha6);*/

    }
}